package com.aaa.reflect;

import com.aaa.ann.MyAnn;
import lombok.Data;
import lombok.extern.java.Log;

import javax.servlet.annotation.WebServlet;
import java.io.Serializable;
import java.util.Objects;

/**
 * @author ：Teacher陈（86521760@qq.com）
 * @date ：Created in 2022/6/14 8:38
 * @description：人类
 * @modified By：
 * @version: 1.0
 */
@MyAnn(name = "xxx")
public class Person  implements Serializable {
    public  static Person person;
    @MyAnn
    private int id;
    private  String name;

    /**
     * 单例模式
     */
    public Person() {
        System.out.println("哥哥被调用啦");
    }

    /**
     * 单例模式
     * @return
     */
    /*public static Person getPerson(){
        if (person==null){
            person=new Person();
            return person;
        }
        return person;
    }*/

    public Person(int id, String name) {
        this.id = id;
        this.name = name;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public String toString() {
        return "Person{" +
                "id=" + id +
                ", name='" + name + '\'' +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o){ return true;}
        if (o == null || getClass() != o.getClass()){ return false;}
        Person person = (Person) o;
        return id == person.id;
    }

    @Override
    public int hashCode() {
        return Objects.hash(id);
    }

    public  void introduce(){
        System.out.println("我的名字是"+name);
    }
    private int add(int a,int b){
        return a+b;
    }
    private int add(int a,int b,int c){
        return a+b+c;
    }

    /**
     * 计算器
     * @param a
     * @param b
     * @param type
     * @return
     */
    public int calc(int a,int b,String type){
        int c=0;
        switch (type){
            case "+":
                c=a+b;
                break;
            case "-":
                c=a-b;
                break;
            case "*":
                c=a*b;
                break;
            case "/":
                c=a/b;
                break;
            default:
                System.out.println("不支持的运算");
                break;
        }
        return c;
    }
}
